//
//  thirdViewController.swift
//  LLNavigationController_Example
//
//  Created by 若望 on 2020/7/21.
//  Copyright © 2020 CocoaPods. All rights reserved.
//

import UIKit

class thirdViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        self.title = "上下滑动"
        // Do any additional setup after loading the view.
        setNaviType()
        self.llBarAlpha = 0.0
        
        let sc = UIScrollView.init(frame: CGRect.init(x: 0, y: 0, width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.height))
        sc.backgroundColor = UIColor.blue
        sc.delegate = self
        sc.contentSize = CGSize.init(width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.height * 2)
        self.view.addSubview(sc)
    }
    

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destination.
        // Pass the selected object to the new view controller.
    }
    */
    func setNaviType()  {
        self.llBarTintColor = UIColor.red
        self.llTintColor = UIColor.white
        self.navigationController?.navigationBar.shadowImage = nil
        
        
        let dic = [NSAttributedString.Key.font : UIFont.systemFont(ofSize: 18), NSAttributedString.Key.foregroundColor: UIColor.black]
        self.llTitleTextAttributes = dic
    }
}
extension thirdViewController : UIScrollViewDelegate {
    func scrollViewDidScroll(_ scrollView: UIScrollView) {
        if scrollView.contentOffset.y > 0.0 {
            self.llBarAlpha = scrollView.contentOffset.y / UIScreen.main.bounds.height
            self.llSetNeedsUpdateNavigationBar()
        } else {
            self.llBarAlpha = 0.0
        }
    }
}
